package com.karaoke.android.kege.widget

import android.content.Context
import android.support.v7.widget.CardView
import android.util.AttributeSet
import android.view.View
import com.karaoke.android.kege.R

/**
 * Created by Allen on 2016/9/28.
 */
class KgeCardView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : CardView(
        context,
        attrs,
        defStyleAttr)
{
    var contentView: View? = null

    init
    {
        val a = context.obtainStyledAttributes(attrs, R.styleable.KgeCardView)
        try
        {
            val layoutResId = a.getResourceId(R.styleable.KgeCardView_cardLayoutResourceID, 0)
            if (layoutResId > 0)
            {
                contentView = inflate(context, layoutResId, this)
            }

        }
        finally
        {
            a.recycle()
        }
    }
}